package juego

import org.uqbar.arena.windows.SimpleWindow
import model.AppModel.ResolverMisterioAppModel
import org.uqbar.arena.windows.WindowOwner
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.layout.ColumnLayout
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.Label
import org.uqbar.commons.utils.Observable
import org.uqbar.arena.widgets.List
import model.AppModel.ExpedientesAppModel
import model.AppModel.ViajarAppModel
import model.AppModel.LugarAppModel
import org.uqbar.arena.bindings.PropertyAdapter
import unq.model.Pais

@Observable
class ResolviendoMisterioWindow extends SimpleWindow<ResolverMisterioAppModel> {
	@Property String lugar1
	@Property String lugar2
	@Property String lugar3
	
	new(WindowOwner parent, ResolverMisterioAppModel model) {
		super(parent, model)
		title = "Resolviendo - " + modelObject.caso.nombre
		this._lugar1 = model.lugar1.nombre
		this._lugar2 = model.lugar2.nombre
		this._lugar3 = model.lugar3.nombre
	}
	override protected addActions(Panel actionsPanel) {
	//throw new UnsupportedOperationException("TODO: auto-generated method stub")
	}
	
	override protected createFormPanel(Panel mainPanel) {
	new Panel(mainPanel) => [
		setLayout(new ColumnLayout(2))
		new Label(it) => [text = "Estas en: " +  modelObject.nombrePaisActual]
		new Label(it) => [text = "Lugares:"]
		
		new Button(it) => [
			caption = "    Viajar    "
			onClick [| new ViajarWindow(this, new ViajarAppModel(this.modelObject.caso, modelObject.caso.paisActual)).open
				close
			]
			
		]
		new Button(it) => [
			caption = lugar1
			onClick [|new ReporteWindow(this,new LugarAppModel(modelObject.lugar1, modelObject.caso.estado), modelObject.caso.nombre).open
		]]
		
	 new Button(it) => [
			caption = "   Expedientes  "
			onClick [|  new VistaExpedientesWindow(this, new ExpedientesAppModel(this.modelObject.caso.juego)).open ]
		]
		new Button(it) => [
			caption = lugar2
			onClick [| new ReporteWindow(this, new LugarAppModel(modelObject.lugar2,  modelObject.caso.estado), modelObject.caso.nombre).open]
		]
		new Button(it) => [
			caption = "Orden de Arresto"
			
			onClick [|new OrdenDeArrestoWindow(this, modelObject).open]
		]
		new Button(it) => [
			caption = lugar3
			onClick [| new ReporteWindow(this, new LugarAppModel(modelObject.lugar3, modelObject.caso.estado), modelObject.caso.nombre).open ]
		]
		new Label(it) => [text = "Orden ya emitida: "
		]
		new Label(it) => [
			modelObject.ordenEmitida
			bindValueToProperty("emitida")
		]
]
		new Panel(mainPanel) =>[ 
			new Label(it) => [text = "recorrido criminal" ]
			new List(it) => [
					bindItemsToProperty("recorridoVillano")
				.setAdapter(new PropertyAdapter(Pais , "nombre"))
			]
			new Label(it) => [text = "desinos fallidos" ]
			new List(it) => [
				bindItemsToProperty("destinosFallidos")
				.setAdapter(new PropertyAdapter(Pais , "nombre"))
			]
			
		]
		
	}
	
}